function userInfoList() {
  return [
    {
      userId: 1,
      avatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
      username: 'admin',
      password: '123456',
      describe: '管理员',
      roles: ['管理员'],
      buttons: ['cuser.detail'],
      routes: ['home'],
      token: 'Admin Token',
    },
    {
      userId: 2,
      avatar: 'https://cube.elemecdn.com/3/7c/3ea6beec64369c2642b92c6726f1epng.png',
      username: 'system',
      password: '123456',
      describe: '系统管理员',
      roles: ['系统管理员'],
      buttons: ['cuser.detail', 'cuser.user'],
      routes: ['home'],
      token: 'System Token',
    },
  ]
}

export default [
  // 用户登录接口
  {
    url: '/api/user/login',
    method: 'post',
    response: ({ body }) => {
      const { username, password } = body
      const checkUser = userInfoList().find(
        (item) => item.username === username && item.password === password,
      )
      if (!checkUser) {
        return {
          code: 'ERROR',
          message: '用户名或密码错误',
        }
      }
      const { token } = checkUser
      return {
        code: 'SUCCESS',
        message: '登录成功',
        data: {
          token,
        },
      }
    },
  },
  // 用户信息接口
  {
    url: '/api/user/getUserInfo',
    method: 'get',
    response: (request) => {
      const { token } = request.headers
      const userInfo = userInfoList().find((item) => item.token === token)
      if (!userInfo) {
        return {
          code: 'ERROR',

          message: '用户信息不存在',
        }
      }
      return {
        code: 'SUCCESS',
        message: '获取用户信息成功',
        data: {
          ...userInfo,
        },
      }
    },
  },
]
